import React, { useState } from 'react'
import { useEffect } from 'react'
import moment from 'moment'
export default function TestEffect({ age }) {
    let [nowTime, setNowTime] = useState(moment().format('YYYY-MM-DD HH:mm:ss'))
    useEffect(()=>{
        let timer = setInterval(()=>{
            console.log(111)
            setNowTime(moment().format('YYYY-MM-DD HH:mm:ss'))
        },1000)
        return ()=>{
            clearInterval(timer)
        }
    },[])
    return (
        <div>
            <h4>useEffect</h4>
            <p>当前事件: {nowTime}</p>
        </div>
    )
}
